/**
 * Voucher 业务逻辑实现类
 * @author WangXinLei
 * @date 2014-09-29
 */
package com.chnbst.bstyun.service.impl;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.chnbst.bstyun.core.base.BaseService;
import com.chnbst.bstyun.core.common.helper.DaoHelper;
import com.chnbst.bstyun.model.pojo.Voucher;
import com.chnbst.bstyun.model.vo.VoucherVo;
import com.chnbst.bstyun.service.VoucherService;

@Transactional
@Service
public class VoucherServiceImpl extends BaseService implements VoucherService {

	//声明日志对象 logback
	private final static Logger logger = LoggerFactory.getLogger(VoucherServiceImpl.class);
	private final static String nameSpace = "com.chnbst.bstyun.mapper.VoucherMapper";
		
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Voucher selectVoucherByVoucherNum(String voucherNum) {
		return (Voucher)DaoHelper.query(nameSpace, "selectVoucherByVoucherNum", voucherNum);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean updateVoucher(Voucher voucher) {
		return DaoHelper.update(nameSpace, "updateVoucher", voucher);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Voucher selectVoucherByNum(String voucherNum) {
		return (Voucher)DaoHelper.query(nameSpace, "selectVoucherByNum", voucherNum);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public int selectVouchersCount(Map<String, Object> map) {
		return DaoHelper.count(nameSpace, "selectVouchersCount", map);
	}

	@SuppressWarnings("unchecked")
	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public List<VoucherVo> selectAllVouchers(Map<String, Object> map) {
		return (List<VoucherVo>)DaoHelper.list(nameSpace, "selectAllVouchers", map);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=false)
	@Override
	public boolean insertVoucher(Voucher voucher) {
		return DaoHelper.insert(nameSpace, "insertVoucher", voucher);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	@Override
	public Voucher selectByVoucherNum(String voucherNum) {
		return (Voucher) DaoHelper.query(nameSpace, "selectByVoucherNum", voucherNum);
	}

}
